package org.jaaksi.kottlindemo.test

import android.graphics.Rect

class Test2 {
  var id: String? = null

  // fixme 当我们访问这个函数的时候，就会回调到action2参数中实现的地方
  lateinit var action: (name: String?, age: Int?) -> Unit
  lateinit var listener: IFo
  var foo: (() -> Unit)? = null

  // action是一个函数，函数作为函数的参数，高阶函数
  fun init(id: String?, action: (name: String?, age: Int?) -> Unit) {
    this.action = action
    this.id = id
  }

  fun init(foo: (() -> Unit)?){
    this.foo = foo
  }

  fun setListener2(listener: IFo) {
    this.listener = listener
  }

  fun cal(num:Int){
    if(num > 0){
      cal(num -1)
    }
    println("$num")
  }

  private fun test() {
    action("2", 1)
    foo?.invoke()
//    listener.foo()
  }

//  val cacheKey =
//    "register/idcardRegisterList?${projectId}&${status}&${page}"

  interface IFo {
    fun foo()
  }
}